package manadvert

import (
	"dub/app/web/manadvert/advertdefine"
	"dub/app/web/manadvert/controller/man"
	"dub/utils"
	"fmt"

	"github.com/astaxie/beego"
)

func RouteAdd() {
	//后台广告管理
	man_advert := &man.AdvertManController{}
	beego.Router("/man/advert", man_advert, "*:Get")
	beego.Router("/man/advert/toadd", man_advert, "*:ToAdd")
	beego.Router("/man/advert/add", man_advert, "*:Add")
	beego.Router("/man/advert/toup", man_advert, "*:ToUp")
	beego.Router("/man/advert/up", man_advert, "*:Up")
	beego.Router("/man/advert/findAdverts", man_advert, "*:FindAdverts")
	beego.Router("/man/advert/action", man_advert, "*:Action")
}

func RegSessionGobStruct() {
	utils.RegSessionGobStruct()
}
func AddFunMap() {
	beego.AddFuncMap("c2int", utils.WebTemplateC2Int)
	beego.AddFuncMap("strhas", utils.WebTemplateStrHasArray)

	//页面调用时不用加被代理的url
	beego.AddFuncMap("authas", WebTemplateAuthHas)
}

func WebTemplateAuthHas(str string, strs []string) bool {
	return utils.WebTemplateStrHasArray(fmt.Sprintf("%s%s", advertdefine.Proxy_Url, str), strs)
}
